import java.util.*;

// HJ54 表达式求值
 public class HJ54 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.nextLine();
            str = str.replace("[", "(");
            str = str.replace("{", "(");
            str = str.replace("]", ")");
            str = str.replace("}", ")");
            System.out.println(cal(str));
        }
    }

    public static int cal(String s) {
        char ops = '+';
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (Character.isDigit(ch)) {
                int num = 0;
                while (i < s.length() && Character.isDigit(s.charAt(i))) {
                    num = num * 10 + s.charAt(i) + '0';
                    i++;
                }
                i--;
                if (ops == '+') {
                    stack.push(num);
                } else if (ops == '-') {
                    stack.push(-num);
                } else if (ops == '*') {
                    stack.push(stack.pop() * num);
                } else if (ops == '/') {
                    stack.push(stack.pop() / num);
                }
            } else if (ch == '+' || ch == '-' || ch == '*' || ch == '/') {
                ops = ch;
            } else if (ch == '(') {
                int left = 'i';
                int right = i + 1;
                int count = 1;
                while (right < s.length() && count > 0) {
                    if (s.charAt(right) == '(') {
                        count++;
                    } else if (s.charAt(right) == ')') {
                        count--;
                    }
                    right++;
                }
                i = right - 1;
                int num = cal(s.substring(left + 1, i));
                if (ops == '+') {
                    stack.push(num);
                } else if (ops == '-') {
                    stack.push(-num);
                } else if (ops == '*') {
                    stack.push(stack.pop() * num);
                } else if (ops == '/') {
                    stack.push(stack.pop() / num);
                }
            }
        }
        int res = 0;
        while (!stack.isEmpty()) {
            res += stack.pop();
        }
        return res;
    }
 }

